<admintpl file="header" />
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Msgtpl/index')}">消息模板</a></li>
        <li class="active"><a href="{:U('Msgtpl/edit')}">消息模板编辑</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" action="{:U('Msgtpl/edit_post')}" method="post">
        <fieldset>
            <div class="control-group">
                <label class="control-label">消息模板标题</label>
                <div class="controls">
                    <input type="text" name="frm[msg_title]" id="msg_title" value="{$msgtpl.msg_title}">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">消息模板类型</label>
                <div class="controls">
                <php>$type_true_checked=($msgtpl['msg_type']=="1")?"checked":"";</php>
                <php>$type_false_checked=($msgtpl['msg_type']=="2")?"checked":"";</php>
                    <input type="radio" name="frm[msg_type]" value="1" {$type_true_checked}>普通消息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="frm[msg_type]" value="2" {$type_false_checked}>系统消息
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">消息模板标识</label>
                <div class="controls">
                    <input type="text" name="frm[msg_ident]" id="msg_ident" value="{$msgtpl.msg_ident}" disabled>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">消息模板内容</label>
                <div class="controls">
                    <textarea name="frm[msg_content]" rows="2" cols="20" id="msg_content" class="inputtext" style="height: 100px; width: 500px;">{$msgtpl.msg_content}</textarea>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">状态</label>
                <div class="controls">
                <php>$state_true_checked=($msgtpl['status']==1)?"checked":"";</php>
                <php>$state_false_checked=($msgtpl['status']==2)?"checked":"";</php>
                    <input type="radio" name="frm[status]" value="1" {$state_true_checked}>启用&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="frm[status]" value="2" {$state_false_checked}>禁用
                </div>
            </div>
        </fieldset>
        <div class="form-actions">
				<input type="hidden" name="id" value="{$msgtpl.id}"/>
				<button type="submit" class="btn btn-primary  js-ajax-submit">{:L('SAVE')}</button>
            <a class="btn" href="javascript:history.back(-1);">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    $(document).ready(function() {
        Wind.css('treeTable');
        Wind.use('treeTable', function() {
            $("#menus-table").treeTable({
                indent : 20
            });
        });
        //  加载所有的省份
        $.ajax({
            type: "get",
            url: "__URL__/sheng", // type=1表示查询省份
            data: {"parent_id": "1", "type": "1"},
            dataType: "json",
            success: function(data) {
                $("#provinces").html("<option value=''>省份</option>");
                $.each(data, function(i, item) {
                    $("#provinces").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
                });
            }
        });
        //  加载所有的市
        $("#provinces").change(function() {
            $.ajax({
                type: "get",
                url: "__URL__/sheng", // type =2表示查询市
                data: {"parent_id": $(this).val(), "type": "2"},
                dataType: "json",
                success: function(data) {
                    $("#citys").html("<option value=''>地级市</option>");
                    $.each(data, function(i, item) {
                        $("#citys").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
                    });
                }
            });
        });
        //  加载所有的区
        $("#citys").change(function() {
            $.ajax({
                type: "get",
                url: "__URL__/sheng", // type =3表示查询区
                data: {"parent_id": $(this).val(), "type": "3"},
                dataType: "json",
                success: function(data) {
                    $("#qu").html("<option value=''>区、县、镇</option>");
                    $.each(data, function(i, item) {
                        $("#qu").append("<option value='" + item.region_id + "'>" + item.region_name + "</option>");
                    });
                }
            });
        });
    });

    setInterval(function() {
        var refersh_time = getCookie('refersh_time_admin_menu_index');
        if (refersh_time == 1) {
            reloadPage(window);
        }
    }, 1000);
    setCookie('refersh_time_admin_menu_index', 0);
    
    function showArea() {
    	var provinces = document.getElementById('provinces');
    	var citys = document.getElementById('citys');
    	var qu = document.getElementById('qu');
        document.getElementById('A_Content').value = provinces.options[provinces.selectedIndex].text + " - " + citys.options[citys.selectedIndex].text + " - " + qu.options[qu.selectedIndex].text + "";
    }
</script>
</body>
</html>